package org.dromara.system.domain.bo;

import org.dromara.system.domain.PayPolicy;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;

import java.util.List;

/**
 * 风控策略业务对象 pay_policy
 *
 * @author Gavino
 * @date 2024-12-24
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = PayPolicy.class, reverseConvertGenerate = false)
public class PayPolicyBo extends BaseEntity {

    /**
     * 策略ID
     */
    @NotNull(message = "策略ID不能为空", groups = { EditGroup.class })
    private Long policyId;

    /**
     * 策略名称
     */
    @NotBlank(message = "策略名称不能为空", groups = { AddGroup.class, EditGroup.class })
    private String name;

    /**
     * 策略类型 1 邮箱验证  2 国家验证
     */
    @NotNull(message = "策略类型不能为空", groups = { AddGroup.class, EditGroup.class })
    private Integer type;

    /**
     * 策略配置
     */
    private String config;

    /**
     * 国家验证类型
     */
    private Integer countryType;

    /**
     * 国家简码
     */
    private String countryCode;

    /**
     * 代理人ID
     */
    private Long agentId;

    @Data
    public static class Config {
        private Integer time = 24; // 间隔时间 单位小时
        private Integer count; // 次数
        private Integer status;  // 状态 1 提交 2 成功 3 失败
        private String validField; // 验证字段 ip  email
        private String fieldName; // 字段名

        public String getStatusStr() {
           return status == 1 ? "提交" : status == 2 ? "成功" : "失败";
        }
    }
}
